Skip to content

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op - #49

Open
hyperpolymath wants to merge 1 commit into
mainfrom
fix/find-exec-terminator
Open

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op#49
hyperpolymath wants to merge 1 commit into
mainfrom
fix/find-exec-terminator

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

tests/e2e/template_instantiation_test.sh ran find … -exec bash -c '…' _ "\$file", which has two defects on one line:

  1. No ; or + terminator — the file does not parse (SC2067).
  2. "\$file" where {} belongs\$file is assigned only inside the -exec body, so in the outer scope it is unset. \$1 arrived empty, file="", and every grep/sed operated on an empty path.

The consequence is worse than a lint error. The placeholder-replacement step silently did nothing, then logged "All placeholder tokens replaced". A test whose entire purpose is to prove instantiation worked was passing without replacing a single token — a plausible cause of estate repos shipping with literal {{project}} still in their sources.

Corrected to ' _ {} \; so find passes each matched path.

Found by an estate-wide sweep of 5,111 scripts across 375 repos: this identical stale copy exists in 30 repositories. rsr-template-repo's own copy is already correct and restructured (371 lines vs the 268 here), so these are stale duplicates that never picked up the upstream fix.

…as a no-op

tests/e2e/template_instantiation_test.sh ran:

    find ... -exec bash -c '
        file="$1"
        ... grep/sed over $file ...
    ' _ "$file"

Two defects in that one line:

  1. No ';' or '+' terminator, so the file does not parse (SC2067).
  2. "$file" is passed where {} belongs. $file is assigned ONLY inside the
     -exec body, so in the outer scope it is UNSET — $1 arrived empty, file=""
     and every grep/sed operated on an empty path.

⚠ The consequence is worse than a lint error: the placeholder-replacement step
SILENTLY DID NOTHING, then logged "All placeholder tokens replaced". A test
whose whole purpose is to prove instantiation worked was passing without
replacing a single token. That is a plausible cause of estate repos shipping
with literal {{project}} tokens still in their sources.

Corrected to "' _ {} \;" so find passes each matched path.

Found by an estate-wide shellcheck sweep of 5,111 scripts across 375 repos:
this identical stale copy exists in 30 repositories. rsr-template-repo's own
copy is already correct and restructured (371 lines vs the 268 here), so these
are stale duplicates that never picked up the upstream fix.
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fd0dd681-684f-4d91-af76-20e2bd370872

📥 Commits

Reviewing files that changed from the base of the PR and between 07218ed and da6a2bd.

📒 Files selected for processing (1)
  • tests/e2e/template_instantiation_test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Hypatia Neurosymbolic Analysis
  • GitHub Check: trufflehog
  • GitHub Check: analyze (actions, none)
  • GitHub Check: Codacy Static Code Analysis
⚠️ CI failures not shown inline (2)

GitHub Actions: Governance / 1_governance _ Check Workflow Staleness.txt: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run bash "$HOME/standards/scripts/check-workflow-staleness.sh" .
 �[36;1mbash "$HOME/standards/scripts/check-workflow-staleness.sh" .�[0m
 shell: /usr/bin/bash -e {0}
 ##[endgroup]
 Staleness Check against Standards SHA: 685341c6544a6ed2ce488028184430456ca07005
 Recency window: <= 50 commits behind HEAD OR <= 14 days old.
 ##[error]governance-reusable.yml pin 5a93d9d57cc0 predates e9c8888769a7 and carries the frozen-Hypatia-scanner-cache defect (`#441`): the first scanner build ever cached is restored forever, so scanner fixes never take effect and the scan reports a FALSE GREEN. Refresh this pin — waiting will not fix it (scripts/propagate-workflow-pins.sh).

GitHub Actions: Governance / governance _ Check Workflow Staleness: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run bash "$HOME/standards/scripts/check-workflow-staleness.sh" .
 �[36;1mbash "$HOME/standards/scripts/check-workflow-staleness.sh" .�[0m
 shell: /usr/bin/bash -e {0}
 ##[endgroup]
 Staleness Check against Standards SHA: 685341c6544a6ed2ce488028184430456ca07005
 Recency window: <= 50 commits behind HEAD OR <= 14 days old.
 ##[error]governance-reusable.yml pin 5a93d9d57cc0 predates e9c8888769a7 and carries the frozen-Hypatia-scanner-cache defect (`#441`): the first scanner build ever cached is restored forever, so scanner fixes never take effect and the scan reports a FALSE GREEN. Refresh this pin — waiting will not fix it (scripts/propagate-workflow-pins.sh).
🔇 Additional comments (1)
tests/e2e/template_instantiation_test.sh (1)

140-140: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed template instantiation tests so placeholder replacement correctly processes each matched file.

Walkthrough

The template instantiation end-to-end test now passes each matched file path directly to the placeholder replacement command.

Changes

Template instantiation test

Layer / File(s) Summary
Forward matched template paths
tests/e2e/template_instantiation_test.sh
The find -exec bash -c invocation now uses {} for each matched path instead of "$file".

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to da6a2

This localized test correction restores the intended placeholder replacement behavior, with no actionable merge-blocking risk remaining after normal checks and review.

Poem

A rabbit checks each path in line

Braces guide the files just fine
The template test runs clear
No misplaced paths appear
One small fix makes results align

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the defect, impact, and correction, but it omits the required template headings and RSR Quality Checklist. It also gives no explicit testing details. Use the repository template. Add the Summary, Changes, RSR Quality Checklist, Testing, and Screenshots sections as applicable. Mark the relevant checklist items and state which tests were run and their results.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: terminating find -exec and passing the {} placeholder.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 36 issues detected

Severity Count
🔴 Critical 6
🟠 High 25
🟡 Medium 5

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in push-email-notify.yml",
    "type": "missing_timeout_minutes",
    "file": "push-email-notify.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 11 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".machine_readable/6a2/PLAYBOOK.a2ml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 11 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".machine_readable/6a2/NEUROSYM.a2ml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 11 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".machine_readable/6a2/AGENTIC.a2ml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 11 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".machine_readable/6a2/ECOSYSTEM.a2ml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 11 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".machine_readable/6a2/META.a2ml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 11 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".machine_readable/6a2/STATE.a2ml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Scorecard): TokenPermissionsID -- Token-Permissions -- 35 day(s) old [STALE]",
    "type": "CSA001",
    "file": ".github/workflows/scorecard.yml",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Scorecard): BranchProtectionID -- Branch-Protection -- 62 day(s) old [STALE]",
    "type": "CSA001",
    "file": "no file associated with this alert",
    "action": "escalate",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/workflow_audit/missing_timeout_minutes -- Hypatia workflow_audit: missing_timeout_minutes -- 62 day(s) old [STALE]",
    "type": "CSA001",
    "file": "push-email-notify.yml",
    "action": "update",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

While this PR correctly addresses the syntax error that caused the find command to fail, the implementation remains effectively a no-op. Both reviewers identified that variables like $placeholder and $value will not expand inside the single-quoted sh -c subshell, meaning the sed command will likely execute with empty parameters.

Furthermore, the test lacks an explicit assertion (e.g., grep) to verify that the template placeholders have actually been replaced. Without this check, future regressions or scoping issues like the one in this PR will continue to fail silently. It is also noted that this script appears to be a duplicate of one maintained in rsr-template-repo, which introduces a risk of maintenance divergence.

About this PR

  • The test script currently lacks an explicit assertion to verify that placeholders (e.g., {{project}}) are actually replaced. Adding a grep check after the replacement loop would ensure that the test fails if the logic is a no-op.

Test suggestions

  • Verify that template placeholders (e.g., {{project}}) are actually replaced in files by asserting file content after the find/sed loop.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that template placeholders (e.g., {{project}}) are actually replaced in files by asserting file content after the find/sed loop.
Low confidence findings
  • This script appears to be a stale duplicate of a script already fixed in rsr-template-repo. Consider consolidating these or pulling the logic from a central source to prevent further divergence.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

fi
done
' _ "$file"
' _ {} \;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

The find syntax is now valid, but the replacement logic remains a no-op because variables like $placeholder and $value are inside single quotes, which prevents the parent shell from expanding them. Additionally, using \; executes the shell script once per file; using + is more efficient for processing multiple files.

Refactor the find command to pass variables as positional arguments to the subshell. For example:

find ... -exec sh -c 'p="$1"; v="$2"; shift 2; for file in "$@"; do sed -i "s/$p/$v/g" "$file"; done' _ "$placeholder" "$value" {} +

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant